Feature/mqtt ha config - #178
Conversation
The cache-busting ADD and REPO_URL/GIT_REF overrides were only needed while testing against this fork's branch; revert to cloning the upstream Nickduino release tag ahead of pushing this branch upstream.
|
Out of curiosity, what limitation are you running into with the current HTTP-based approach? Is there a specific use case that requires MQTT instead? |
|
I personally prefer using MQTT, since it’s event-based rather than continuously polling every few seconds. |
|
Thanks for putting this together, and sorry for the slow back and forth. I'd rather explain my thinking properly than leave this sitting. Where I've landed: I'm inclined not to merge this as it stands, but I want to talk it through rather than close it silently, because it's very possible I'm missing something. Why I'm hesitant Pi-Somfy already has a complete MQTT interface with Home Assistant auto-discovery built in. Run it standalone with The add-on has intentionally been the other path: web UI and scheduler, no broker, no MQTT dependency.
That's the add-on's reason for existing, and it works well as it is. Adding MQTT to it means two ways to do the same thing, five new options to document and support, and more surface for me to keep working across HA releases. Also more confused users trying to understand why there are parameters they don't need. What would change my mind Is there something the standalone install can't do for you here? If there's a real blocker, something about your setup that makes standalone impractical, I'd want to know, because that would change my view. A smaller version I would merge If the answer is essentially "standalone works, but running the add-on is much more convenient", I'm still open to it, just in a much leaner form. HA add-ons can declare MQTT_HOST=$(bashio::services mqtt "host")
MQTT_PORT=$(bashio::services mqtt "port")
MQTT_USER=$(bashio::services mqtt "username")
MQTT_PASSWORD=$(bashio::services mqtt "password")That drops One technical note either way The None of this is meant to dismiss the work. I appreciate you taking the time, and the polling versus events argument is a fair one. I just want to be careful about what goes into the add-on. Let me know what you think. |
|
No worries on the back-and-forth :) I see the add-on as a way to expose all config options like this more accessibly, rather than needing a second, separate install just to get MQTT. |
|
Perfect, This is exactly what I had in mind, thanks for reworking it. Nice and small. Four things before I merge, two functional and two docs. If you can apply them and confirm it still works on your setup, that would be great. 1. Write
|
…docs Four fixes requested in PR review: 1. Write EnableDiscovery = true alongside the other MQTT keys — without it, an existing operateShutters.conf where EnableDiscovery is false or missing gets MQTT with no auto-discovery, defeating the point of the enable_mqtt toggle. 2. Guard against a missing [MQTT] section before the key-writing loop. The loop's `sed -i "/^\[MQTT\]/a ..."` silently no-ops if [MQTT] isn't in the file at all (e.g. a pre-existing config from before MQTT support existed). 3. Flesh out translations/en.yaml so every add-on option shows a real name/description on the Configuration tab instead of the raw key. 4. DOCS.md: note that the enable_mqtt toggle only finds a broker running as a Home Assistant add-on — an external broker needs Pi-Somfy run standalone with -m instead.
…g.yaml version dynamically
Brings this branch's somfy-ha-addon/ up to date with all of feature/mqtt-ha-config's work, since the two are meant to merge together (this branch gets the add-on discoverable via the standard repository install flow; the other adds MQTT auto-discovery support). - Optional MQTT bridge via a new enable_mqtt toggle, pulling broker details from the Supervisor mqtt service (e.g. Mosquitto add-on) rather than asking the user to re-enter them. - EnableDiscovery + missing-[MQTT]-section guard, translations/en.yaml labels for every option, and a DOCS.md note on external brokers (review feedback from PR Nickduino#178). - Fixed config.yaml's version being "3.0.0", which isn't a real upstream Pi-Somfy tag and broke the Dockerfile's source clone. build.sh now reads the version from config.yaml instead of a second hardcoded copy. - CHANGELOG.md rewritten with real, user-facing release notes.




Add optional MQTT support to the HA add-on
Adds an optional MQTT bridge to the Pi-Somfy Home Assistant add-on, alongside the existing web UI/scheduler.
mqtt_server,mqtt_port(default1883),mqtt_user,mqtt_password,mqtt_client_id(defaultsomfy-mqtt-bridge) — all optional, MQTT stays fully disabled unlessmqtt_serveris set.run.shwrites the[MQTT]config section and passes-mtooperateShutters.pyonly whenmqtt_serveris configured.Dockerfilenow installspaho-mqtt(previously skipped since-mwas never used).DOCS.mdto document the new options and MQTT auto-discovery behavior.No behavior change for existing installs that leave
mqtt_serverblank.